/**
 * 
 */
package cu.ds.logicalsync.fytasrealm.communication;

import java.util.Set;

import cu.ds.logicalsync.fytasrealm.communication.event.PeerStatusListener;
import cu.ds.logicalsync.fytasrealm.communication.model.PeerInfo;
import cu.ds.logicalsync.fytasrealm.model.World;

/**
 * PeerStatusServiceProvider handle the following operations:
 * <ul>
 * 	<li>Notify listener when there is new Peer connected to the game</li>
 * 	<li>Notify listener when there is a Peer disconnected from the game</li>
 *  <li>Determine whether given name is already in used by other Peer in the system</li>
 *  <li>TODO: Others</li>
 * </ul>
 * 
 * @author r.vashira
 */
public interface PeerStatusServiceProvider extends ServiceProvider {
	
	/**
	 * Determine whether given name is already in used by other Peer in the system
	 * @param clientName
	 * @return true if specified peer name is already existed in the system, otherwise false
	 */
	public boolean isNameExisted(String clientName);
	
	/**
	 * login to the system, verify whether name is duplicated with other peers or not
	 * @param peerName name of current peer
	 * @return PeerInfo information for current peer
	 */
	public PeerInfo login(String peerName);
	
	
	/**
	 * Get latest Peer Collection this client know so far.
	 * @return Set<PeerInfo> collection of PeerInfo
	 */
	public Set<PeerInfo> getPeerCollection();
	
	
	/**
     * Register a PeerStatus listener. The PeerStatus listener will be called 
     * whenever there is a event occur by the PeerStatus Service.
     *
     *  @param listener the PeerStatusListener
     */
	public void addListener(PeerStatusListener listener);
	
	/**
	 * Remove a PeerStatus listener which was previously registered with
 	 * {@link #addListener(PeerStatusListener) addListener()}.
	 * 
	 * @param listener The listener to be removed.
     *  @return true if the listener was successfully removed, false otherwise
	 */
	public boolean removeListener(PeerStatusListener listener);
}
